package com.源码分析;

import java.util.concurrent.CompletableFuture;

import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import reactor.core.publisher.Mono;

public class FromFutureDemo {

	private Logger logger = LoggerFactory.getLogger(FromCompletionStage.class);

	@Test
	public void test() {
		CompletableFuture<String> f = CompletableFuture.supplyAsync(() -> {
			try {
				Thread.sleep(500);
			} catch (InterruptedException e) {
				e.printStackTrace();
			}
			logger.info("helloFuture");
			return "helloFuture";
		});
		Mono.fromFuture(f).subscribe(x -> {
			logger.info(x);
		});
		logger.info("main");

		try {
			Thread.sleep(2000);
		} catch (InterruptedException e) {
			e.printStackTrace();
		}
	}

}
